<?php
	/**
 * author: Kirk Amoah
 * date:3/21/2014
 * description: A district class that manages all the duties of the district
 */
	include_once("adb.php");
	
	
class district extends adb{
		function district(){
			adb::adb();
		}
		/* A function that gets all the districts in the DB */
		function get_all_district(){
			$query="select * from district";
			return $this->query($query);
			}
		
		/* A function that gets all the districts Ids*/
		function get_all_id($id){
			$query="select * from district where district_id=$id";
			return $this->query($query);
		}
			
		/* A function that adds to the  districts DB*/
		function add_district($district_name,$district_capital,$region_id){
		$query="insert into district set district_name='$district_name',district_capital='$district_capital',region_id='$region_id'";
		return $this->query($query);
		}
		/* A function that enables the user to edit data in district DB */
		function update_district($id,$district_name,$district_capital,$region_id){
		$query="Update district set district_name='$district_name',district_capital='$district_capital',region_id='$region_id' where district_id='$id'";
		if(!$this->query($query)){
				return false;
			}
			return true;
		}
		
		/* A function that deletes from the district DB*/
		function delete_district($id){
		$query="Delete from district where district_id=$id";
		if(!$this->query($query)){
				return false;
			}
			return true;
		}
		/* A function that searches through the district DB*/ 
		function search_district($district_name){
		$query="Select * from district where district_name like '%$district_name%'";
			$search = $this->query($query);
			return $this->fetch();
		}
}
?>
			